package com.foreverwin.jzymes.report.grind.controller;

import com.foreverwin.jzymes.common.domain.ActivityLog;
import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.grind.domain.GrindCheck;
import com.foreverwin.jzymes.production.grind.domain.GrindCheckNc;
import com.foreverwin.jzymes.report.grind.service.IGrindLogReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report/grind")
public class GrindReportController {
    @Autowired
    IGrindLogReportService grindLogReportService;

    /**
     * 研磨产出报表
     *
     * @param jsonMap
     * @return
     */
    @RequestMapping("/GrindLogReport")
    public AjaxResult GrindLogReport(@RequestParam Map< String ,Object > jsonMap ){
        jsonMap.put("site",CommonMethods.getSite());
        try{
           List<ActivityLog> logs = grindLogReportService.selectgrindOut( jsonMap );
            return AjaxResult.returnSuccess().put("value" , logs);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

    /**
     * 研磨检验报表
     *
     * @param jsonMap
     * @return
     */
    @RequestMapping("/GrindCheckReport")
    public AjaxResult GrindCheckReport(@RequestParam Map< String ,Object > jsonMap ){
        jsonMap.put("site",CommonMethods.getSite());
        try{
            List<GrindCheck> logs = grindLogReportService.selectgrindCheck( jsonMap );
            return AjaxResult.returnSuccess().put("value" , logs);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

    @RequestMapping("/grindCheckNC")
    public AjaxResult grindCheckNC(@RequestParam Map< String ,Object > jsonMap ){
        jsonMap.put("site",CommonMethods.getSite());
        try{
            List<Map<String, Object>> logs = grindLogReportService.selectgrindCheckNC( jsonMap );
            return AjaxResult.returnSuccess().put("value" , logs);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

}
